#ifndef TD4550SERIALTHREAD_H
#define TD4550SERIALTHREAD_H
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QThread>
#include <QTimer>
#include "tunkia.h"

class TD4550SerialThread: public QObject
{
    Q_OBJECT;//Q_OBJECT宏，使程序可以用信号与槽机制
protected:


public:
    TD4550SerialThread();
    QSerialPort * simpleSerial;
    int 串口状态=0;
    QList<int> comConj;
    QString comNo;
    int BaudTime;
    QString 接收数据;
    int 错误类型;//接收帧的错误类型
    int 工位;
    int TD校准步骤;


private:
    QTimer *timer1,*timer2;
    TD源的输出值 TD4550输出;
    void 检查源输出(QString 接收数据);
    int 检查步骤;
    int 检查次数;


signals:
    //void openedCom4550(int 串口状态);//告诉其它窗口，串口是否已打开
    void TD4550State(QString 错误信息,bool 错误码, int 状态码);
    void sendReceiveData(QByteArray data);//将接收到的数据发到其它窗口中

public slots:
    void getConj(QString comNo,QList<int> comConj);
    void openConj(QString comNo,QList<int> comConj);
    void sendData(QByteArray data);//用以接收其它窗口传递过来的数据，再发送到串口
    void confirmTD4550();
    void calibrate_TD4550(int 校准步骤);
    void TD4550Step();

private slots:
    void ReadData();
    void waitRead();


};

#endif // TD4550SERIALTHREAD_H
